<template>
  <div class="payroll-page">
    <div class="page-header">
      <div class="page-title">我的工资单</div>
    </div>

    <!-- <div class="year-picker">
      <van-icon class="pick-left-icon" name="play" style="transform: rotate(180deg);" @click="lastYear"/>
      <span class="pick-year">{{ year }}</span>
      <van-icon :class="['pick-left-icon', disabledNext && 'disabled']" name="play" @click="nextYear"/>
    </div> -->

    <div class="page-body">
      <div class="payroll-list">
        <div class="payroll-item" v-for="item in list" :key="item.MONTH_ID" @click="viewDetials(item.MONTH_ID)">
          <div class="payroll-month">{{ item.MONTH_ID }}</div>
          <div class="payroll-card">
            <div class="card-label">实发工资(元)</div>
            <div class="card-value">{{ item.ACTUAL_FEE || 0 }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { payrollList } from '@/api/publicline/board.js'

import Vue from 'vue'
import { USER_INFO } from '@/store/mutation-types'

export default {
  data() {
    return {
      // year: "",
      // disabledNext: true,
      list: []
    };
  },
  created() {
    // this.year = new Date().getFullYear();
    // this.maxYear = this.year;
    this.getPayRoll()
  },
  methods: {
    // 工资单
    async getPayRoll() {
      const res = await payrollList({ loginId: Vue.ls.get(USER_INFO).username })
      const { result, success } = res
      if (success) {
        this.list = result
      }
    },
    viewDetials( monthId ) {
      this.$open.call(this, '/publicline/payroll/detials', { monthId })
    },

    // nextYear() {
    //   if ( this.disabledNext ) return;
    //   this.year++;
    //   if ( this.year >= this.maxYear ) this.disabledNext = true;
    // },
    // lastYear() {
    //   this.year--;
    //   if ( this.year < this.maxYear ) this.disabledNext = false;
    // },
  }
}
</script>


<style lang="less" scoped>
.payroll-page {

  .page-header {
    padding: 10px;
    text-align: center;
    background: #FFF;
    font-weight: bold;
    color: #555;
  }

  .year-picker {
    padding: 6px 20px;
    background: #FFF;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    justify-content: center;

    .pick-left-icon, .pick-right-icon {
      display: inline-block;
      padding: 6px 22px;
      color: rgb(90, 159, 255);

      &.disabled {
        color: rgb(177, 177, 177);
      }
    }
    .pick-year {
      padding: 5px 20px 2px;
      margin: 0 10px;
      background: rgba(117, 175, 255, 0.21);
      border-radius: 4px;
      line-height: 14px;
      color: rgb(26, 121, 255);
    }
  }

  .page-body {

    .payroll-list {
      padding: 10px;

      .payroll-item {
        margin-bottom: 10px;

        .payroll-month {
          padding: 2px 10px;
          color: #666;
        }
        .payroll-card {
          padding: 14px 10px;
          display: flex;
          justify-content: space-between;
          background: #FFF;
          border-radius: 4px;

          .card-label {
            color: #888;
          }
          .card-value {
            color: #F00;
            font-size: 16px;
          }
        }
      }
    }
  }
}
</style>